function download(el, url, fileName) {
    const div = document.querySelector(el);

    div.onclick = () => {
        const a = document.createElement('a')
        a.setAttribute('download', fileName || '文件');
        a.setAttribute('href', url);
        a.click();
    }
}

function downloadUrlFile(url) {
    const xhr = new XMLHttpRequest();
    xhr.open('GET', url, true);
    xhr.responseType = 'blob';
    xhr.setRequestHeader('Authorization', 'Basic a2VybWl0Omtlcm1pdA==');
    xhr.onload = () => {
        if (xhr.status === 200) {
            // 获取图片blob数据并保存
            saveAs(xhr.response, 'abc.jpg');
        }
    };

    xhr.send();
}